/** DBMetaDataTest.java
 
   The program demonstrates how to access database/schema related information. There are a couple of
hundreds of methods in DatabaseMetaData interface. The inferface is implememented by JDBC driver
provider. An instance of DatabaseMetaData object is created by Connection's getMetaData() method.

*/

import java.sql.*;

public class DBMetaDataTest {

	public static void main(String args[]) {
		Connection cnn = null;
		String url = "jdbc:oracle:thin:@cheval.cs.csubak.edu:1521:TEST",
		user="scott", passwd="tiger";
 
	    try {
		DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
		cnn = DriverManager.getConnection(url, user, passwd);
		DatabaseMetaData dbMData = cnn.getMetaData();

		System.out.println("Database Product Name: " + dbMData.getDatabaseProductName());
		System.out.println("Database Version No  : " + dbMData.getDatabaseProductVersion());
		System.out.println("JDBC Driver Name     : " + dbMData.getDriverName());
		System.out.println("JDBC Driver Version  : " + dbMData.getDriverVersion());
		System.out.println("JDBC Driver Major Ver: " + dbMData.getDriverMajorVersion());
		System.out.println("JDBC Driver Minor Ver: " + dbMData.getDriverMinorVersion());

	   } catch (SQLException e) {
		try { cnn.close() ; } catch (SQLException ex) {}
		e.printStackTrace(); }
	}
} 